<?php
include $this->Render('header.php');
?>
<script type="text/javascript">
	window.br_id = '<?php echo $this->id;?>';
</script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/branch_contractlist.js"></script>
<style type="text/css">
.ext-strict .x-form-text {
	background:#fff;
	border:1px solid #e1e1e1;
	height:22px;	
}

.x-form .x-panel {
	margin-bottom:5px;
}
/**
.x-form-check-group {
	border:1px solid #e1e1e1;
	background:#FFF;
}	
**/
</style>

<!--S 公共顶部-->
<div id="page-north">
    <?php
		include $this->Render('nav.php');
	?>
    
    <!-- S 查询条件 -->
    <div class="admin-search-box admin-search-reset">
        <ul class="admin-search-ul">
			<?php
				if(Purview::checkPurview($this->UserConfig['Id'],array('crm','sys','contract', 'add'))){
			?>
            <li>
                <a class="nc-btn-input J-ico-xinzeng" href="javascript:;"><em class="ico-jia mr5"></em>新增</a>
            </li>
			<?php
				}
				if(Purview::checkPurview($this->UserConfig['Id'],array('crm','sys','contract', 'edit'))){
			?>
            <li>
                <a class="nc-btn-input J-ico-xiugai" href="javascript:;"><em class="ico-xiugai mr5"></em>编辑</a>
            </li>
			<?php
				}
				if(Purview::checkPurview($this->UserConfig['Id'],array('crm','sys','contract', 'remove'))){
			?>
            <li>
                <a class="nc-btn-input J-ico-del" href="javascript:;"><em class="ico-del mr5"></em>删除</a>
            </li>
			<?php
				}
			?>
        </ul>
        <div class="clear"></div>
    </div>
    <!-- E 查询条件 -->
    
</div>
<!--E 公共顶部 -->

<!-- S 数据列表 -->
<div id="topic-grid"></div>
<!-- E 数据列表 -->

<?php include $this->Render('footer.php'); ?>


<script type="text/javascript">
$(document).ready(function(e) {
	$(".J-ico-xinzeng").on('click',function(){
		xinzengItem();	
	});

	$(".J-ico-del").on('click',function(){
		contractremove();
		return false;	
	});

	$(".J-ico-xiugai").on('click',function(){
		editItem();

	});
});


function xinzengItem(){
    var dizhi = window.location.href;
    var dizhis =dizhi.split("=");
    var id = dizhis[1];
	var xinzengHtml = '<iframe width="100%" height="100%" id="xinzeng_item" name="xinzeng_item" src="/branch/operate/option/contractadd?id='+id+'" frameborder="0"></iframe>';
	var win = new Ext.Window({
			title:'新增合同',
			closeable:true,
			closeAction:'hide',
			modal:true,
			width:800,
			height:700,
			resizable:false,
			plain:true,
			layout:'fit',
			html:xinzengHtml
		});
		
		win.show(this);		
}

function editItem(){
	var count =App.grid.getSelectionModel().getCount();
	if(count < 1){
		Ext.Msg.minWidth = 120;
		Ext.Msg.alert('提示','请选择合同');
		return false;
	}
	var selectRow = App.grid.getSelectionModel();
	var selectObj = selectRow.getSelected();
    var bcid = selectObj['data']['bc_id'];
	var xinzengHtml = '<iframe width="100%" height="100%" id="xinzeng_item" name="xinzeng_item" src="/branch/operate/option/contractedit?bc_id='+bcid+'" frameborder="0"></iframe>';
	var win = new Ext.Window({
			title:'编辑合同',
			closeable:true,
			closeAction:'hide',
			modal:true,
			width:800,
			height:700,
			resizable:false,
			plain:true,
			layout:'fit',
			html:xinzengHtml
		});
		
		win.show(this);		
}
function contractremove(){
	var count =App.grid.getSelectionModel().getCount();
	if(count < 1){
		Ext.Msg.minWidth = 120;
		Ext.Msg.alert('提示','请选择合同');
		return false;
	}
	var selectRow = App.grid.getSelectionModel();
	var selectObj = selectRow.getSelected();
    var bcid = selectObj['data']['bc_id'];
	Ext.Msg.confirm('提示','您确定要删除该合同?',function(btn){
        if(btn=='yes'){
            $.post('/branch/operate/option/contractremove/',{"bc_id":bcid},function(data){
                Ext.Msg.alert('提示',data['msg'],function(){
                    App.store.load({params:{'page':1, 'rp':25}});   
                });
            },'json');      
        }
    }); 
}
</script>
